package com.bdqn.design;

import com.bdqn.design.computer.Computer;
import com.bdqn.design.computer.impl.DivComputer;
import com.bdqn.design.proxy.log.LoggerCGLIBProxyFactory;
import com.bdqn.reflect.pojo.Person;

/**
 * Test08LoggerProxyDynamicCGLIB（使用CGLIB实现动态代理）
 * JDK9以上版本需要添加JVM参数：--add-opens java.base/java.lang=ALL-UNNAMED
 *
 * @author LILIBO
 * @since 2023-10-10
 */
public class Test08LoggerProxyDynamicCGLIB {

    public static void main(String[] args) {
        Person from = new Person("曹源", 5000, "", "湖南郴州");
        Person to = new Person("袁嗣善", 200, "", "湖南郴州");

        // 使用CGLIB实现动态代理
        // PersonService personService = LoggerCGLIBProxyFactory.create(PersonServiceImpl.class);
        // boolean result = personService.transfer(from, to, 5000);
        // System.out.println("[返回结果]：" + result);

        Computer computer = LoggerCGLIBProxyFactory.create(DivComputer.class);
        computer.calculate(10, 5);
    }

}
